'''
函数进阶
'''
# 全局变量
a = 10
for x in range(2):
    print('循环中', a)
    print(x)
print(x)


def func1():
    print('函数中', a)
    print(x)


func1()


# 局部变量

def func2(aa):
    b = 50
    print(aa, b)

    def wrapper():
        c = 20
        print(c)
        pass

    return wrapper()


print('-----------------------')
# global
a1 = 100


def func3():
    global a1
    a1 = 200
    print('inner:', a1)


func3()
print(a1)


# nonlocal
def func4():
    a2 = 100

    def func5():
        print('func5', a2)

print('*-----------------------')
# 匿名函数

func5 = lambda c, b: c + b
print(func5(1,2))
# 练习：
func6 = lambda year: year % 400 == 0 or (year % 4 == 0 and not year % 100 == 0)
print(func6(2100))
